﻿<Window x:Class="Notoric.Gui.Windows.SelectPictureFromResourcesDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ls="clr-namespace:LukasKopenec.LocalizationSupport;assembly=LocalizationSupport"
        xmlns:vm="clr-namespace:Notoric.ViewModel;assembly=ViewModel"
        xmlns:cvr="clr-namespace:Notoric.Gui.Converters"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="{ls:Localize Windows.SelectPictureFromResourcesDialog.Title}" Height="285" Width="456"
        WindowStartupLocation="CenterScreen" Background="#FFF0F0F0"
        ResizeMode="NoResize">
    <Window.Resources>
        <cvr:CollectionFilterSortConverter x:Key="collectionConverter" Filter="ChildrenCollection_Filter"/>
        <cvr:ResourceToImageSourceConverter x:Key="imageConverter"/>
    </Window.Resources>
    <StackPanel>
        <StackPanel Orientation="Horizontal" Background="White" Height="200" HorizontalAlignment="Stretch" Margin="7 7 7 0">
            <DockPanel LastChildFill="True">
                <Label Content="{ls:Localize Windows.SelectPictureFromResourcesDialog.Resource}" DockPanel.Dock="Top"/>
                <TreeView x:Name="PART_ResourcesTree" Width="200" DockPanel.Dock="Bottom" SelectedItemChanged="PART_ResourcesTree_SelectedItemChanged"
                          ItemsSource="{Binding ResourcesRoot.Children, Mode=OneWay, Converter={StaticResource collectionConverter}, ConverterParameter='Name'}">
                    <TreeView.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding Children, Mode=OneWay, Converter={StaticResource collectionConverter}, ConverterParameter='Name'}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Path=Icon, Mode=OneWay}" Height="16" Width="16" Margin="0 0 4 0"/>
                                <TextBlock Text="{Binding DisplayName, Mode=OneWay}" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                </TreeView>
            </DockPanel>
            <DockPanel LastChildFill="True" Margin="20 0 0 0">
                <Label Content="{ls:Localize Windows.SelectPictureFromResourcesDialog.Preview}" DockPanel.Dock="Top"/>
                <Border Width="200" BorderThickness="1" BorderBrush="Black" DockPanel.Dock="Bottom">
                    <Image x:Name="PART_ImagePreview" Source="{Binding ElementName=PART_ResourcesTree,Path=SelectedItem,Converter={StaticResource imageConverter}}"/>
                </Border>
            </DockPanel>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 10 7 0">
            <Button x:Name="PART_OK" Content="{ls:Localize Windows.OKButton}" Width="60" IsDefault="True" Click="PART_OK_Click" IsEnabled="False" />
            <Button x:Name="PART_Cancel" Content="{ls:Localize Windows.CancelButton}" Margin="6 0 0 0" Width="60" IsCancel="True" Click="PART_Cancel_Click" />
        </StackPanel>
    </StackPanel>
</Window>
